#include "RegisterPairsOfCloudsModel.h"

#include "core/AppDirectory.h"

namespace {
const QString UserFilename = "pcl.register_pairs_of_clouds_model.json";
}

RegisterPairsOfCloudsModel::RegisterPairsOfCloudsModel()
    : BasePclModel()
{
    setPclHelpPage("https://pcl.readthedocs.io/projects/tutorials/en/master/pairwise_incremental_registration.html");
}

RegisterPairsOfCloudsModel& RegisterPairsOfCloudsModel::get()
{
    static RegisterPairsOfCloudsModel instance;
    if (instance.filename().isEmpty()) {
        instance.setFilename(AppDirectory::get().getAppDocFile(UserFilename));
        instance.load();
    }
    return instance;
}

void RegisterPairsOfCloudsModel::fromJson(const QJsonObject& json, QStringList& errorList)
{
    BasePclModel::fromJson(json, errorList);

    pcdFile_ = json["pcdFile"].toString(pcdFile_);
}

QJsonObject RegisterPairsOfCloudsModel::toJson() const
{
    QJsonObject json = BasePclModel::toJson();

    json.insert("pcdFile", QJsonValue(pcdFile_));

    return json;
}
